#pragma once

//#include "Object/Object.h"

#include "Misc/CommonMacros.h"
#include "Misc/StdHead.h"
#include "Misc/Guid.h"

#ifdef USING_SOURCE_LOCATION
	#include <source_location>
#endif

class RObject;
class CClass;

//create a object have two stages
//1.allocate and invoke constructor
//2.invoke a Init function :  PostLoadFromAsset() or FirstTimeInitializeObject()
WHENGINE_API RObject* NewObjectFirstStage(CClass* InClass, RObject* InOwner
#ifdef USING_SOURCE_LOCATION
        ,const std::source_location& CreateLocation = std::source_location::current()
#endif   
);

WHENGINE_API RObject* NewObjectInner(CClass* InClass, RObject* InOwner
#ifdef USING_SOURCE_LOCATION
        ,const std::source_location& CreateLocation = std::source_location::current()
#endif   
);

template<typename RObjectType>
RObjectType* NewObjectInner(RObject* InOwner
#ifdef USING_SOURCE_LOCATION
        ,const std::source_location& CreateLocation = std::source_location::current()
#endif   
)
{
    return (RObjectType*)NewObjectInner(RObjectType::StaticClass(),InOwner
#ifdef USING_SOURCE_LOCATION
    ,CreateLocation
#endif
    );
}

template<typename RObjectType>
RObjectType* NewObjectInner(CClass* InClass,RObject* InOwner
#ifdef USING_SOURCE_LOCATION
        ,const std::source_location& CreateLocation = std::source_location::current()
#endif   
)
{
    return (RObjectType*)NewObjectInner(InClass,InOwner
#ifdef USING_SOURCE_LOCATION
    ,CreateLocation
#endif
    );
}

namespace WH
{
    WHENGINE_API void DestroyObject(RObject* InObject);
};